//
//  SZTTabbarViewController.m
//  OC-微博
//
//  Created by z先生 on 17/2/7.
//  Copyright © 2017年 SZT. All rights reserved.
//

#import "SZTTabbarViewController.h"
#import "SZTHomeTableViewController.h"
#import "SZTMessageTableViewController.h"
#import "SZTDiscoverTableViewController.h"
#import "SZTMeTableViewController.h"

@interface SZTTabbarViewController ()

@end

@implementation SZTTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //首页
    SZTHomeTableViewController * home = [[SZTHomeTableViewController alloc]init];
    
    [self setupViewController:home title:@"首页" imageName:@"tabbar_home" selectedImageName:@"tabbar_home_selected"];
    
    //消息
    SZTMessageTableViewController * message = [[SZTMessageTableViewController alloc]init];
    
    [self setupViewController:message title:@"消息" imageName:@"tabbar_message_center" selectedImageName:@"tabbar_message_center_selected"];
    
    //发现
    
    SZTDiscoverTableViewController * discover = [[SZTDiscoverTableViewController alloc]init];
    
    [self setupViewController:discover title:@"发现" imageName:@"tabbar_discover" selectedImageName:@"tabbar_discover_selected"];
    
    //我
    SZTMeTableViewController * me = [[SZTMeTableViewController alloc]init];
    
    [self setupViewController:me title:@"我" imageName:@"tabbar_profile" selectedImageName:@"tabbar_profile_selected"];
    
}

-(void)setupViewController:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName{
    
    vc.title = title;
    
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:vc];
    
    [self addChildViewController:nav];
    
}

@end
